//
//  FirstSetPwdViewController.m
//  FKGW
//
//  Created by song ce on 2017/3/3.
//  Copyright © 2017年 song ce. All rights reserved.
//

#import "FirstSetPwdViewController.h"

@interface FirstSetPwdViewController ()
@property (weak, nonatomic) IBOutlet UITextField *pwd1;
@property (weak, nonatomic) IBOutlet UITextField *pwd2;

@end

@implementation FirstSetPwdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.pwd1.secureTextEntry = YES;
    self.pwd2.secureTextEntry = YES;

}



- (IBAction)commit:(id)sender {
    if(!self.pwd1.text.length&&!self.pwd2.text.length){
        [MBProgressHUD showTipMessageInWindow:@"请输入密码"];
        return;
    }
    if(self.pwd1.text.length<6||self.pwd1.text.length>16){
        [MBProgressHUD showTipMessageInWindow:@"请输入6-16位密码"];
        return;
    }
    if(![self.pwd1.text isEqualToString:self.pwd2.text]){
        [MBProgressHUD showTipMessageInWindow:@"两次密码输入不一致"];
        return;
    }
    
    // 2.50更改密码接口
    NSString *userName = [AppDelegate appDealegate].huanxinUserName;
    NSDictionary *paraDic = @{
                              @"userId":USERID,
                              @"passWord":self.pwd1.text,
                              @"userName":userName
                              };
    //    __weak typeof(self)  weakSelf = self;
    [Tools AFNetworkingRequestTypePostWithUrl:CHANGEPASSWORD paramters:paraDic  afterResultBlock:^(NSDictionary *resultDic) {
        if([resultDic[@"flag"] isEqualToString:@"true"]){
            NSDictionary *dataDic = resultDic[@"data"];
            if([dataDic isKindOfClass:[NSNull class]]) return ;
            if([dataDic[@"status"] isEqualToString:@"true"]){
                [MBProgressHUD showTipMessageInView:@"'密码修改成功"];
            }
        }
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
